package com.ys.erp.stage_emp_service.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ys.erp.common.enums.EnableEnum;
import com.ys.erp.entity.data.bean.Right;
import com.ys.erp.entity.service.IRightService;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.stage_emp_service.bean.vo.RightVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 南山
 * @date 2025/08/08 14:37
 */
@RequiredArgsConstructor
@Service
public class RoleServiceImpl implements RoleService{
    private final IRightService iRightService;

    @Override
    public List<RightVO> getRoleListByType(StageEmpDTO empDto, String type) {
        QueryWrapper<Right> rightQw = new QueryWrapper<>();
        if (!"hz0".equals(empDto.getShopCode())) {
            rightQw.lambda().eq(Right::getIsPrivateRight, EnableEnum.NO.getEnable());
        }
        rightQw.lambda().eq(Right::getRightType, type);
        List<Right> list = iRightService.list(rightQw);
        return list.stream()
                .map(it -> new RightVO().setId(it.getId())
                        .setRightKey(it.getRightKey())
                        .setParentId(it.getParentId())
                        .setRightDescribe(it.getRightDescribe()))
                .collect(Collectors.toList());
    }
}
